//
//  ClockViewController.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/9.
//

#import "ClockViewController.h"
#import "ClockModel.h"
#import "ClockHeaderView.h"
#import "TemplateFoundDetailsModel.h"
#import "TemplateFoundDetailsDXXZTableViewCell.h"
#import "TemplateFoundDetailsDXXLTableViewCell.h"
#import "TemplateFoundDetailsSZSRTableViewCell.h"
#import "TemplateFoundDetailsDHWBTableViewCell.h"
#import "TemplateFoundDetailsDHTableViewCell.h"
#import "ClockFooterView.h"
#import "ClockDTDKTableViewCell.h"
#import "CancelTaskViewController.h"
#import "ClockDKDRWTableViewCell.h"

#import "ReportExceptionViewController.h"
#import "TransferTaskViewController.h"

#import "SYAudio.h"
#import "VoiceView.h"
#import "YCMenuView.h"
#import "CombinedPunchViewController.h"
@interface ClockViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong) ClockModel * model;
@property (nonatomic ,strong)  UIButton * zdspBtn ;

@property (nonatomic ,strong) UILabel * leftlab;

@property (nonatomic ,strong) UIView * DKbtn;
@end

@implementation ClockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupView];
    // Do any additional setup after loading the view.
}
- (void)setupView{
    self.NoDataHidden = YES;
    self.shutDownBack = YES;
    
    UIView * topview = [UIView new];
    topview.backgroundColor = KcolorHex(@"#0967FF");
    [self.view addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.offset(0);
        make.height.offset(Knav_HeightX);
    }];
    MJWeakSelf
    UIView * backview = [UIView new].addClickBlock(^{
        [weakSelf popViewController];
    });
    [topview addSubview:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(44);
        make.left.bottom.offset(0);
        make.width.offset(kwt(120));
    }];
    
    UIImageView * leftimg = kimageView(@"white_path");
    [backview addSubview:leftimg];
    [leftimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(20);
        make.left.offset(kwt(10));
        make.centerY.offset(0);
    }];
        
    UILabel * leftlab = [DTKTool labelWithText:@"打卡" andFont:kCFont(18) andTextColor:UIColor.whiteColor];
    [backview addSubview:leftlab];
    self.leftlab = leftlab;
    [leftlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(43));
        make.centerY.offset(0);
    }];
    
    UIButton * zdspBtn = [UIButton buttonWithType:0];
    self.zdspBtn= zdspBtn;
    zdspBtn.addimg([UIImage imageNamed:@"more_function"]).addNormalColor(UIColor.whiteColor).addFont(kCFont(18)).addTarget(self,@selector(openSZ));
    [topview addSubview:zdspBtn];
    [zdspBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.centerY.offset(KTop/2);
    }];
    
    
    UIView * buttomview = [UIView new];
    buttomview.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:buttomview];
    [buttomview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(63)+ KSafeAreaBottomHeight);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#ECECEC");
    [buttomview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.offset(0);
        make.height.offset(0.5);
    }];
    
    UIView * QXView = [UIView new];
    QXView.addClickBlock(^{
        [weakSelf openQX];
    });
    [buttomview addSubview:QXView];
    [QXView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(0);
        make.height.offset(kwt(63));
        make.width.offset(kwt(85));
    }];
    
    UIImageView * QXimg = kimageView(@"clock_in_cancel_task");
    [QXView addSubview:QXimg];
    [QXimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(kwt(10));
        make.width.height.offset(kwt(26));
    }];
    
    UILabel * QXlab = [DTKTool labelWithText:@"取消任务" andFont:kFont(14) andTextColor:KcolorHex(@"#4B4E50")];
    [QXView addSubview:QXlab];
    [QXlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(kwt(37));
    }];
    
    UIView * JJView = [UIView new];
    JJView.addClickBlock(^{
        [weakSelf openJJ];
    });
    [buttomview addSubview:JJView];
    [JJView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.height.offset(kwt(63));
        make.left.offset(kwt(85));
        make.width.offset(kwt(85));
    }];
    
    UIImageView * JJimg = kimageView(@"clock_in_transmit");
    [JJView addSubview:JJimg];
    [JJimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(kwt(10));
        make.width.height.offset(kwt(26));
    }];
    
    UILabel * JJlab = [DTKTool labelWithText:@"交接任务" andFont:kFont(14) andTextColor:KcolorHex(@"#4B4E50")];
    [JJView addSubview:JJlab];
    [JJlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(kwt(37));
    }];
    
    
    UIView * DKbtn = [UIView new];
    self.DKbtn = DKbtn;
    DKbtn.addClickBlock(^{
        [weakSelf TJApi];
    });
    DKbtn.backgroundColor = [UIColor gradientColorWithSize:CGSizeMake(kwt(150), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")];
    [DTKTool YJ:kwt(10) andView:DKbtn];
    [buttomview addSubview:DKbtn];
    [DKbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.offset(kwt(150));
        make.height.offset(kwt(48));
        make.top.offset(kwt(8));
    }];
    
    UIImageView * dkimg = kimageView(@"daka");
    [DKbtn addSubview:dkimg];
    [dkimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.centerX.offset(kwt(-22));
        make.height.width.offset(kwt(18));
    }];
    
    UILabel * dklab = [DTKTool labelWithText:@"打卡" andFont:kFont(16) andTextColor:UIColor.whiteColor];
    [DKbtn addSubview:dklab];
    [dklab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.centerX.offset(kwt(13));
    }];
    
    [self.view addSubview:self.tableview];
    self.tableview.backgroundColor = KcolorHex(@"#ECEDEE");
    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(topview.mas_bottom);
        make.bottom.equalTo(buttomview.mas_top);
    }];
    
    [self loadNewData];
    
}
///指导视频
- (void)openSZ{
    NSMutableArray * array = [NSMutableArray array];
    MJWeakSelf
    YCMenuAction * m = [YCMenuAction actionWithTitle: @"指导视频" image:[UIImage imageNamed:@"show-how"] handler:^(YCMenuAction *action) {
        [weakSelf openZDSP];
    }];
    [array addObject:m];
    
    
    if(self.model.mergeList.count < 1 && self.model.issueCode == 0){
        YCMenuAction * m2 = [YCMenuAction actionWithTitle: @"合并打卡" image:[UIImage imageNamed:@"clock_in"] handler:^(YCMenuAction *action) {
            CombinedPunchViewController * vc = [CombinedPunchViewController new];
            vc.ID = weakSelf.ID;
            NSMutableArray * pondNameList = [NSMutableArray array];
            for (pondModelListModel * m in weakSelf.model.pondModelList) {
                [pondNameList addObject:m.name];
            }
            vc.pondNameList = pondNameList;
            vc.tissueName = weakSelf.model.tissueName;
            vc.seledBlock = ^(NSArray<CombinedPunchModel *> * _Nonnull array, NSString * _Nonnull str) {
                NSMutableArray * mergeList = [NSMutableArray array];
                NSMutableArray <pondModelListModel *> * newModelArray = [NSMutableArray array];

                for (CombinedPunchModel * m in array) {
                    [mergeList addObject:m.ID];
                    for (CombinedPunchTissueListModel * bzmodel in m.tissueList) {
                        pondModelListModel * model = [pondModelListModel new];
                        model.name = [bzmodel.pondNameList componentsJoinedByString:@","];
                        model.tissueName = bzmodel.tissueName;
                        [newModelArray addObject:model];
                    }
               
                }
                NSLog(@"数组%@",newModelArray);
                weakSelf.model.mergeList = mergeList;
                [weakSelf.model.copynamepondModelList addObjectsFromArray:newModelArray];
                weakSelf.model.tissueNameStr = nil;
                weakSelf.model.tissueNameStrH = 0;
                weakSelf.leftlab.text = @"合并打卡";
                [weakSelf.tableview reloadData];
                [weakSelf loadNewData];
            };
            [weakSelf.navigationController pushViewController:vc animated:YES];
        }];
        [array addObject:m2];
    }
    
    YCMenuView * menuview = [YCMenuView menuWithActions:array width:kwt(135) relyonView:self.zdspBtn];
    menuview.menuColor = KcolorHex(@"#4C4C4C");
    menuview.textColor = UIColor.whiteColor;
    menuview.textFont = kFont(14);
    menuview.separatorColor = KcolorHex(@"#636161");
    menuview.disMissBlock = ^{
        
    };
    [menuview show];
    
}
///指导视频
- (void)openZDSP{
    if(self.model.videoUrl.length > 0){
        [DTKTool openImagAndVideo:@[[self.model.videoUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]] andopenview:self.view andIndex:0];
    } else {
        [self.view showWarning:@"无指导视频"];
    }
  
}
///交接任务
- (void)openJJ{
    TransferTaskViewController * vc = [TransferTaskViewController new];
    vc.ID = self.model.ID;
    [self.navigationController pushViewController:vc animated:YES];
}
///取消任务
- (void)openQX{
    CancelTaskViewController * vc = [CancelTaskViewController new];
    vc.ID = self.model.ID;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)TJApi{
    if([self.model TJHUDStr].length > 0){
        [self.view showWarning:[self.model TJHUDStr]];
        return;
    }
//    if(self.model.configureItem == 1 || self.model.pondModelList.count > 1){///多池塘的统一配置
//        for (pondModelListModel * model in self.model.pondModelList) {//重新赋值给每个鱼塘
//            NSMutableArray * taskItemModelList = [NSMutableArray array];
//            for (TemplateFoundDetailsTaskItemModelListModel * itemModel in self.model.superTaskModelArray) {
////                for (TemplateFoundDetailsTaskItemModelListModel * tempitemmodel in itemModel.pondModelList.firstObject.taskItemModelList) {///重新赋值回去
////                    [taskItemModelList addObject:[TemplateFoundDetailsTaskItemModelListModel yy_modelWithJSON:[tempitemmodel yy_modelToJSONString]]];
////                }
//                [taskItemModelList addObject:[TemplateFoundDetailsTaskItemModelListModel yy_modelWithJSON:[itemModel yy_modelToJSONString]]];
//
//            }
//            model.taskItemModelList = taskItemModelList;
//        }
//    }
    [self.view showBusyHUD];
    NSMutableDictionary * dict = [self.model TjDict];
    [dict setObject:self.ID forKey:@"id"];
    [SCNetManger PostCardAddWithDict:dict andCompetionHandlerBlock:^(HTTPDicBase * model) {
        [self.view hideBusyHUD];
        if(model.code == 200){
            [self.view showWarning:model.message];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                // 2秒后执行的代码
                [self.navigationController popViewControllerAnimated:YES];
            });
        } else {
            [self.view showWarning:model.message];
        }
    }];
}
- (void)loadNewData{
    [self.view showBusyHUD];
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.ID forKey:@"id"];
    if(self.model.mergeList.count > 0){
        [dict setObject:self.model.mergeList forKey:@"mergeList"];
    }
    [SCNetManger PostCardDetailWithDict:dict andCompetionHandlerBlock:^(HTTPDicBase * model) {
        [self.view hideBusyHUD];
        if(model.code == 200){
            ClockModel * tempmodel = [ClockModel yy_modelWithDictionary:model.result];
            if(self.model.mergeList.count > 0){
                tempmodel.tissueNameStr = self.model.tissueNameStr;
                tempmodel.mergeList = self.model.mergeList;
                [self.DKbtn mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.width.offset(kwt(345));
                }];
                self.DKbtn.backgroundColor = [UIColor gradientColorWithSize:CGSizeMake(kwt(345), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")];

            }
            self.model = tempmodel;
            //数据处理 出来统一配置时多项选择
            if(self.model.configureItem > 0 ){///统一配置或者分别配置
                for (pondModelListModel * pondModel in self.model.pondModelList) {///鱼塘列表
                    for (TemplateFoundDetailsTaskItemModelListModel * itemModel in pondModel.taskItemModelList) {///任务列表
                        itemModel.configureItem = self.model.configureItem;
                    }
                }
            }
            [self.tableview reloadData];
        } else {
            [self.view showWarning:model.message];
        }
    }];
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    ClockHeaderView * view = [ClockHeaderView NewView];
    MJWeakSelf
    view.openBtnClickBlock = ^(TemplateFoundDetailsTaskItemModelListModel * _Nonnull model) {
        ///处理统一多选的数据
        for (pondModelListModel * listModel in weakSelf.model.pondModelList) {///每个鱼塘
            for (TemplateFoundDetailsTaskItemModelListModel * itemModel in listModel.taskItemModelList) {///每个任务
                if(itemModel.pattern == 1){///多选
                    for (TemplateFoundDetailsItemModelListModel * listModel in itemModel.itemModelList) {///多选任务项
                        for (TemplateFoundDetailsItemModelListModel * NewItemModel in model.itemModelList) {///统一的每个任务
                            if([listModel.templateItemId isEqualToString:NewItemModel.templateItemId]){
                                listModel.checkedFlag = NewItemModel.checkedFlag;
                            }
                        }
                    }
                }
            }
        }
        
        [weakSelf.tableview reloadData];
    };
    view.openYCBlock = ^{
        [weakSelf.navigationController pushViewController:[ReportExceptionViewController new] animated:YES];
    };
    view.model = self.model;
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return self.model.HeaderView;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    MJWeakSelf
    ClockFooterView * view = [ClockFooterView NewView];
    view.model = self.model;
    view.openImageBlock = ^(ClockModel * _Nonnull model, int index) {
        [weakSelf openImgArray:model.cardImgArray andindex:index];
    };
    view.deleteImageBlock = ^(ClockModel * _Nonnull model, int index) {
        [weakSelf.model.cardImgArray removeObjectAtIndex:index];
        [weakSelf.model.TJcardImgArray removeObjectAtIndex:index];
        [weakSelf.tableview reloadData];
    };
    view.openAddImageBlock = ^(ClockModel * _Nonnull model) {
        [weakSelf addressWithBlock:^(NSString * _Nonnull address) {
            if([address isEqualToString:@"未获取到位置信息"] || address.length < 1){
                [weakSelf.view showWarning:@"未获取到位置信息"];
                return;
            }
            [weakSelf openXJWithType:ACMediaPickerSourceFromCamera andBlock:^(NSArray<ACMediaModel *> * _Nonnull list) {
                [SCNetManger PostuploadFilesWithImg:list.firstObject.image andAddress:address CompletionHandler:^(NSString * _Nonnull url, NSString * _Nonnull previewUrl, UIImage * _Nonnull img) {
                    [weakSelf.model.cardImgArray addObject:previewUrl];
                    [weakSelf.model.TJcardImgArray addObject:url];
                    [weakSelf.tableview reloadData];
                }];
            }];
        }];
    };
    view.reloadBlock = ^{
        [weakSelf.tableview reloadData];
    };
    return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return self.model.FooterViewH;
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(self.model.pondModelList.count > 1){
        if(self.model.configureItem == 1){///统一配置使用任务为数量
            return  self.model.superTaskModelArray.count;
        }
        return  self.model.pondModelList.count;
    } else {
        return self.model.pondModelList.firstObject.taskItemModelList.count;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(self.model.pondModelList.count > 1){
        if(self.model.configureItem == 1){///统一配置使用任务为数量
            return self.model.superTaskModelArray[indexPath.row].DKDRWDYTCellH;
        }
        return self.model.pondModelList[indexPath.row].YTDKcellH;
    } else {
        return self.model.pondModelList.firstObject.taskItemModelList[indexPath.row].DKCellH;
    }
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    MJWeakSelf
  
    if(self.model.pondModelList.count > 1){///多池塘
        if(self.model.configureItem == 1){///统一配置使用任务为数量
            ClockDKDRWTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ClockDKDRWTableViewCell"];
            if (cell == nil) {
                cell = [[ClockDKDRWTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ClockDKDRWTableViewCell"];
            }
            cell.openReloadBlock = ^{
                [weakSelf.tableview reloadData];
            };
            cell.model = self.model.superTaskModelArray[indexPath.row];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell ;
        }
        ClockDTDKTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ClockDTDKTableViewCell"];
        if (cell == nil) {
            cell = [[ClockDTDKTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ClockDTDKTableViewCell"];
        }
        cell.openReloadBlock = ^{
            [weakSelf.tableview reloadData];
        };
        cell.ponmodel = self.model.pondModelList[indexPath.row];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell ;
    }else {///单池塘
        TemplateFoundDetailsTaskItemModelListModel * model = self.model.pondModelList.firstObject.taskItemModelList[indexPath.row];
        if(model.pattern == 1) {///多选
         
            TemplateFoundDetailsRWDXXZTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TemplateFoundDetailsRWDXXZTableViewCell"];
            if (cell == nil) {
                cell = [[TemplateFoundDetailsRWDXXZTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TemplateFoundDetailsRWDXXZTableViewCell"];
            }
            cell.model = model;
            cell.openReloadBlock = ^{
                [weakSelf.tableview reloadData];
            };
            cell.openHUDBlock = ^(NSString * _Nonnull str) {
                [weakSelf.view showWarning:str];
                [weakSelf.tableview reloadData];
            };
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell ;
            
        } else if( model.pattern == 2){///单选
            TemplateFoundDetailsDXXLZRWTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TemplateFoundDetailsDXXLZRWTableViewCell"];
            if (cell == nil) {
                cell = [[TemplateFoundDetailsDXXLZRWTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TemplateFoundDetailsDXXLZRWTableViewCell"];
            }
            cell.model = model;
            ///下拉单选
            cell.openXLDXBlock = ^(TemplateFoundDetailsTaskItemModelListModel * _Nonnull Model, TemplateFoundDetailsItemModelListModel * _Nonnull itemModel) {
                NSMutableArray * nameArray = [NSMutableArray array];
                int i = 0;
                int selectIndex = 0;
                for (TemplateFoundDetailsItemModelListModel * itemmodel in Model.itemModelList) {
                    [nameArray addObject:itemmodel.name];
                    if(itemmodel == itemModel){
                        selectIndex = i;
                    }
                    i ++;
                }
                [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",model.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                    for (TemplateFoundDetailsItemModelListModel * itemmodel in Model.itemModelList) {
                        if([itemmodel.name isEqualToString:resultModel.value]){
                            itemmodel.checkedFlag = 1;
                        } else {
                            itemmodel.checkedFlag = 0;
                        }
                    }
                    [weakSelf.tableview reloadData];
                }];
            };
            cell.openReloadBlock = ^{
                [weakSelf.tableview reloadData];
            };
            cell.openHUDBlock = ^(NSString * _Nonnull str) {
                [weakSelf.view showWarning:str];
            };
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            return cell ;
        } else if(model.pattern == 3){///数字输入
            
            TemplateFoundDetailsSZSRTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TemplateFoundDetailsSZSRTableViewCell"];
            if (cell == nil) {
                cell = [[TemplateFoundDetailsSZSRTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TemplateFoundDetailsSZSRTableViewCell"];
            }
            cell.model = model;
            cell.openReloadBlock = ^{
                [weakSelf.tableview reloadData];
            };
            cell.openHUDBlock = ^(NSString * _Nonnull str) {
                [weakSelf.view showWarning:str];
                [weakSelf.tableview reloadData];
            };
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell ;
        } else if(model.pattern == 4){///单行文本
            TemplateFoundDetailsDHWBTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TemplateFoundDetailsDHWBTableViewCell"];
            if (cell == nil) {
                cell = [[TemplateFoundDetailsDHWBTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TemplateFoundDetailsDHWBTableViewCell"];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.model = model;
            return cell ;
        } else if(model.pattern == 5){///多行文本
            
            TemplateFoundDetailsDHTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TemplateFoundDetailsDHTableViewCell"];
            if (cell == nil) {
                cell = [[TemplateFoundDetailsDHTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TemplateFoundDetailsDHTableViewCell"];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.model = model;
            return cell ;
        }
    }
    UITableViewCell * cell =  [UITableViewCell new];
    return cell ;
    
}
- (void)dealloc{
    [[SYAudio shareAudio] audioStop];
}

@end
